import {
  mapGetters
} from 'vuex'
export default {
  data() {
    return {}
  },
  props: {
    /** 是公海 默认是客户 */
    isSeas: {
      type: Boolean,
      default: false
    }
  },

  computed: {
    ...mapGetters(['crm']),
    // 能否查看详情
    canShowDetail() {
      let t = this.type ? this.type : this.crmType
      console.log(this.crm,'查看详情',t,this.crm[t])
      return this.crm && this.crm[t] && this.crm[t].read
    },
    // 是否可编辑
    canEdit() {
      console.log(this.crmType,this.type,'是否可编辑：111');
      let res = false;
      if (this.isSeas) res = true;
      if (this.type) {
        if (this.type == "customer"||this.type == 'ideacustomer') {
          res = this.crm[this.crmType].update;
        } else if (this.type == "okcustomer" || this.type == 'complete') {
          res = false;
        } else if (this.type == "seas" || this.type =='wo') {
          res = true;
        }
      // } else if (this.crmType == 'contract') {
      //   res = this.detailData.receivablesMoney && parseFloat(this.detailData.receivablesMoney.lasahmMoney) == 0
      } else {
        res = this.crm[this.crmType].update || true;
      }
      console.log(this.crmType,this.type,'是否可编辑：111', res);
      return res;
    },
  },

  watch: {
    id(v) {
      console.log(this.canShowDetail,'this.canShowDetail11111')
      if (this.canShowDetail) {
        this.getDetial()
      }
    }
  },

  mounted() {
    console.log(this.canShowDetail,'this.canShowDetail22222')
      if (this.canShowDetail) {
        this.getDetial()
      }
  },

  methods: {
    /** 顶部头 操作 */
    detailHeadHandle(data) {
      if (data.type === 'edit') {
        this.isCreate = true
      } else if (data.type === 'delete') {
        this.hideView()
      }
      this.$emit('handle', data)
    }
  },

  deactivated: function () {}

}
